(function(){

	if (!window.CJ) {
		window.CJ = {};
	}
	if (!window.CJ.plugin) {
		window.CJ.plugin = {};
	}

	function voiceBtnDisable() {
		var elem = document.getElementById('voiceBtn');
		elem.removeChild(elem.parentElement);
	}
	CJ.plugin.voice = {
		init : function () {
			try{
				this.DeviceAPI = document.getElementById('voice');
				this.DeviceAPI.onbuttonenable = function(e){
					if (!e) {
						voiceBtnDisable();
					}
				};
			} catch  (err) {
				console.log(err.message);
			}
		},
		startRecognition: function () {
			try{
				return this.DeviceAPI.startRecognition();
			} catch  (err) {
				console.log(err.message);
			}
		}
	};

	$(document).ready(function(){
		CJ.plugin.voice.init();
	});

})();